<?php

     session_start();

    if (!isset($_SESSION['logged'])) {
        @header("Location: login.php");
        die;
    }

    if (!file_exists("../config.php")) {
        @header("Location: ../install.php");
        die;
    }

    include("../global_conf.php");
    include($site->langdir."/languages.php");
    require_once("./admin_lib.php");

    if (isset($_POST['change_lang'])) {
        $_SESSION['lang'] = array_search($_POST['language'], $languages);
        change_user_lang($_SESSION['logged'], $_SESSION['lang']);
    }

    if (isset($_POST['submit_change_credentials'])) {
        if ($_SESSION['logged'] != $_POST['usrid'])
            $err=1;
        else {
            $credentials=array();
            $credentials['username']=$_POST['change_username'];
            $credentials['password']=$_POST['change_password'];
            if (!empty($credentials['username']) && !empty($credentials['password'])) {
                if (strcmp($_POST['change_password'], $_POST['repeat_change_password']))
                        $err=$_LANG['error no match passwords'];
                else {
                    change_credentials ($_POST['usrid'], $credentials);
                }
            }
            else
                $err=1;
        }
    }

    require_once($site->langdir."/".$_SESSION['lang'].".lang.php");

    $accounttab="class=\"active\"";
    require_once("./include/sections.php");
    include("./include/admin_header.php");
?>
    <div id="page">
    <div id="page-bgtop">
    <div id="page-bgbtm">
        <div id="content">
    <?php
        if (isset($err)) {
            echo $_LANG['error invalid values'];
        }
        get_account_section();
    ?>
        </div>
        <div style="clear: both">&nbsp;</div>
    </div>
    </div>
    </div>
<?php
    include("./include/admin_footer.php");
?>